//
//  MTNavViewController.m
//  Travel
//
//  Created by lanou3g on 15/11/18.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "MTNavViewController.h"
#import "UIBarButtonItem+Extension.h"
#import "UIView+Extension.h"
@interface MTNavViewController ()

@end

@implementation MTNavViewController


//初始化

+(void)initialize
{
    //设置整个项目的item的样式
    UIBarButtonItem *item = [UIBarButtonItem appearance];
    
    //设置字体样式，颜色--普通状态
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    //textAttrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:17];
    [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    
    //设置不可用状态
    
    UIBarButtonItem *disItem = [UIBarButtonItem appearance];
    
    
    
    
    NSMutableDictionary *disTextAttrs = [NSMutableDictionary dictionary];
    disTextAttrs[NSForegroundColorAttributeName] = [UIColor cyanColor];
    disTextAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:17];
    
    
    [disItem setTitleTextAttributes:disTextAttrs forState:UIControlStateDisabled];
    
    
    
    
}

/**
 *  重写这个方法目的：能够拦截所有push进来的控制器
 *
 *  @param viewController 即将push进来的控制器
 */
///*-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
//{
//    if (self.viewControllers.count > 0) {
//        //// 这时push进来的控制器viewController，不是第一个子控制器（不是根控制器）
//        /* 自动显示和隐藏tabbar */
//
//        viewController.hidesBottomBarWhenPushed = YES;
//        //设置导航栏的内容
//        
//       // viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(back) image:@"" highImage:@""];
//        // 设置左边的返回按钮
//        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(back) image:@"navigationbar_back" highImage:@"navigationbar_back_highlighted"];
//        
//        // 设置右边的更多按钮
//        viewController.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(more) image:@"navigationbar_more" highImage:@"navigationbar_more_highlighted"];
//        
//    }
//    
//        //push到下一个界面
//        
//        [self pushViewController:viewController animated:YES];
//        
//        
//}



- (void)back
{
#warning 这里要用self，不是self.navigationController
    // 因为self本来就是一个导航控制器，self.navigationController这里是nil的
    [self popViewControllerAnimated:YES];
}

- (void)more
{
    [self popToRootViewControllerAnimated:YES];
}



- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
